package com.ming.controller;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ming.domain.BookCategory;
import com.ming.service.BookCategoryService;

@RestController
@SpringBootApplication
@RequestMapping("/bookCategory")
public class BookCategoryController {

    @Autowired
    private BookCategoryService bookCategoryService;

    @RequestMapping("/{id}")
    public Optional<BookCategory> getBookCategory(@PathVariable Integer id) {
        return bookCategoryService.findOne(id);
    }

    @RequestMapping("/list")
    public List<BookCategory> getBookCategoryList(){
        return bookCategoryService.findAll();
    }

    @RequestMapping("/query")
    public List<BookCategory> queryByDate(){
        LocalDate today = LocalDate.now();
        return bookCategoryService.findByDate(today);
    }
}
